package com.iut.sujet1.manager;

import java.util.Scanner;

import com.iut.sujet1.exception.AppException;
import com.iut.sujet1.metier.Personne;


public class PersonneManager {
	
	public void affichePers(Personne pers){
		System.out.println(pers);
	}

	public Personne SaisirPersonne(){
		
		Personne pers = new Personne();
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		boolean err = false;
		
		System.out.println("Saisi d'une personne : ");
		System.out.println("Nom : ");
		pers.setNom(sc.nextLine());
		
		System.out.println("Prenom : ");
		pers.setPrenom(sc.nextLine());
		do{
			err = false;
			System.out.println("Age : ");
			try {
				pers.setAge(sc.nextInt());
			} catch (AppException e) {
				err=true;
				System.out.println(e.getMessage());
			} catch (Exception ex) {
				err=true;
				System.out.println("Saisir un age valide");
				
			}finally{
				
				sc =  new Scanner(System.in);
			}
		
		}while(err);
		
		return pers;
	}
}
